import count from '@feidao/web/atom/nodejs/db/count';
import query from '@feidao/web/atom/nodejs/db/query';
import { IBaseTable } from '@feidao/web/atom/nodejs/db/interfaces';

import { spaceid, systemid } from './config';

interface Message {
	filter: {};
	page_size: number;
	page_no: number;
	asc: string[];
	desc: string[];
}

export default async function atom(msg: Message, action_id: string, session_id: string) {
	const { exec, prepare } = query(action_id, session_id, spaceid, systemid);
	prepare('accessory_data', ['serial_no', 'file_size', 'file_name'], msg.filter, msg.page_size, msg.page_no, msg.asc, msg.desc);
	const [res] = await exec();

	return res;
}
